public class OrderActiveState implements OrderState {

	public OrderInterface order;
	public ClosedOrder closeOrder;

	public OrderActiveState(OrderInterface o) {
		order = o;
	}

	@Override
	public String initializeOrder() {
		return "Order already Initialised";
	}

	@Override
	public String activeOrder() {
		order.setState(order.getOrderActiveState());
		return "Order Activated";
	}

	@Override
	public String partialOrder() {
		System.out.println("order has been changed to partial state.");
		order.setState(order.getOrderPartialState());
		return "Order has been changed to partial state! ";
	}

	@Override
	public String closeOrder(boolean isOrderFulfilled) {

		order.setState(order.getOrderClosedState());
		if (isOrderFulfilled) {
			System.out.println("Active -> Order CLosed (Fulfilled)! ");
			closeOrder = new OrderFulfilled();
		} else {
			System.out.println("Active -> Order CLosed (Cancelled)! ");
			closeOrder = new OrderCancelled();

		}
		closeOrder.closeOrder();
		return "Order Closed";
	}

}
